<link rel="stylesheet" href="/styles.css" type="text/css">
<?
include ('../../sessions.php');
include ('../../variables.php');
include('functions.php');

$save_type='MySQL';


if(!$desc) $desc = "desc";
if($limit) $limit = $limit+0;
else $limit = '50';
if(!$orderby) $orderby='2';
if(!$uniq_ip) $uniq_ip='yes';


$dbh = get_master_connect();
if (!$dbh) {

        echo "We are sorry but we cannot process your request at the moment<BR>";
        exit_now();
}
?>
	
<table border='0'class='bTable' cellpadding='0' cellspacing='0'  width='100%'  bgcolor='#DDDDDD' >
        <tr>
        <td align='center'>
                <b>REFERER STATISTIC</b>
        </td>
        </tr>
</table>
<center>
<br>
<table border="0" cellpadding="0" cellspacing="0" width='90%' class='bTable'>
<tr>
	      <td colspan='20'>
	      <table  class='bTable' width='100%'>
	      <form action='' method='POST'>
	      <tr>
	      <td >
	  	<?
			$opt = "    	
			<input type='radio' name='desc' value='desc' >Descend &nbsp;&nbsp;
		    	<input type='radio' name='desc' value='asc'  >Ascend &nbsp;&nbsp;";
			$newopt = str_replace("value='$desc'","value='$desc' checked",$opt);
			echo $newopt;
		?>
	    		
		</td>
	      <td>
	      Limit : <input type='text' name='limit' size='3' value='<?=$limit?>'>
	      </td>
	       <td>
	        Type :	
<?
$opt="";
$SQL="select type from referers group by type";
if (!($result = @mysql_db_query($session_db_name, $SQL, $dbh)))
            return "ERROR\n".$SQL."\n";
echo "<select name='type'>\n <option value=''>all</option>";
while($row=mysql_fetch_row($result)){
   if($row[0]){
       $kkk="";
       if($row[0]==$type) $kkk=" selected ";
       echo  "<option  value='$row[0]' $kkk >$row[0] </option>&\n";
   }
    
}
?>
	
</td>
<td>
	Referer Group : 
	<select name='group'>
	<option value=''>none</option>
	<?
		include('../refererGroups/functions.php');
		$grouplist = get_all_referer_groups('select');
		$newgroup = str_replace("'$group'","'$group' selected",$grouplist);
		echo $newgroup;
	
	?>
	</select>
</td>	
<td>
	IP : 
	<select name='uniq_ip'>
	<?
		$opt = "<option value=''>all</option>
			<option value='yes'>uniq</option>";

                $newopt = str_replace("'$uniq_ip'","'$uniq_ip' selected",$opt);
                echo $newopt;
	?>
	</select>
</td>
<td> <input type='submit' value='SET'></td>
</form>
</table>
</td>
</tr>
	      
	
<tr><th>^</th><th>referer</th><th>type</th>
<th><a class='links' href='index.php?s=<?=$s;?>&orderby=1&io=in_&desc=<?=$desc?>&limit=<?=$limit?>&type=<?=$type;?>&ut=<?=$ut;?>&group=<?=$group;?>&uniq_ip=<?=$uniq_ip;?>'>1h</a></th>
<th><a class='links' href='index.php?s=<?=$s;?>&orderby=2&io=in_&desc=<?=$desc?>&limit=<?=$limit?>&type=<?=$type;?>&ut=<?=$ut;?>&group=<?=$group;?>&uniq_ip=<?=$uniq_ip;?>'>24h</a></th>
<th><a class='links' href='index.php?s=<?=$s;?>&orderby=3&io=in_&desc=<?=$desc?>&limit=<?=$limit?>&type=<?=$type;?>&ut=<?=$ut;?>&group=<?=$group;?>&uniq_ip=<?=$uniq_ip;?>'>1w</a></th>
<th><a class='links' href='index.php?s=<?=$s;?>&orderby=4&io=in_&desc=<?=$desc?>&limit=<?=$limit?>&type=<?=$type;?>&ut=<?=$ut;?>&group=<?=$group;?>&uniq_ip=<?=$uniq_ip;?>'>1m</a></th>
<th><a class='links' href='index.php?s=<?=$s;?>&orderby=5&io=in_&desc=<?=$desc?>&limit=<?=$limit?>&type=<?=$type;?>&ut=<?=$ut;?>&group=<?=$group;?>&uniq_ip=<?=$uniq_ip;?>'>global</a></th>
</tr>
<? echo lister($orderby,$desc,$limit,$ut,$type,$group,$uniq_ip); ?>
</TABLE>
</center>
